<%@ page import="org.springside.core.Constants"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<fmt:message key="footer_message_1" var="footer_message_1" />
<fmt:message key="footer_message_2" var="footer_message_2" />
<fmt:message key="footer_message_3" var="footer_message_3" />
<fmt:message key="footer_message_4" var="footer_message_4" />
<fmt:message key="footer_message_5" var="footer_message_5" />
<fmt:message key="footer_message_6" var="footer_message_6" />
<fmt:message key="footer_message_7" var="footer_message_7" />
<%
	response.setHeader("Pragma", "No-cache");
	response.setHeader("Cache-Control",
			"no-store, no-cache, must-revalidate");
	response.setHeader("Expires", "Sat, 1 Jan 2000 12:00:00 GMT");
%>

<%
	if(request.getLocale().toString().toLowerCase().startsWith("en")){%>
		<c:set var="languages" value="english" />
	<%
	}else if(request.getLocale().toString().equalsIgnoreCase("zh_hk") || request.getLocale().toString().equalsIgnoreCase("zh_tw") || request.getLocale().toString().equalsIgnoreCase("zh_mo")){
	%>
		<c:set var="languages" value="complexChinese" />
	<%
	}else{
	%>
		<c:set var="languages" value="simpleChinese" />
	<%
	}
%>
<script language="javascript" type="text/javascript">
<% if (!"true".equals(Constants.EAS)) { %>
<c:if test="${empty sessionScope.loginUser}">
	top.location.href='<c:url value="/login/login.jsp?login_error=7"/>';
</c:if>
<% } %>
//count++;   
//var str = $('divResult2').innerHTML;   
//$('divResult2').innerHTML = str + "count = " + count + ": " + new Date() + "<br>";
<c:if test="${false && !empty newMessageCountRing && newMessageCountRing > 0}">
//window.focus();
try {
   <c:if test="${sessionScope.loginUser.theme=='kingdee'}">
	<c:if test="${languages==null || languages=='simpleChinese'}">
		document.getElementById('messageImg').src="<c:url value="/themes/${sessionScope.loginUser.theme}/images/top_message2.gif"/>";
	</c:if>
	<c:if test="${languages!=null && languages=='complexChinese'}">
		document.getElementById('messageImg').src="<c:url value="/themes/${sessionScope.loginUser.theme}/images/top_message2.gif"/>";
	</c:if>
	<c:if test="${languages!=null && languages=='english'}">
		document.getElementById('messageImg').src="<c:url value="/themes/${sessionScope.loginUser.theme}/images/top_message2_en.gif"/>";
	</c:if>
	
	document.getElementById('messageImg').title="${footer_message_6}${newMessageCountRing==null?'0':newMessageCountRing}${footer_message_7}";
	</c:if>
	if (count == 0) {
		document.getElementById('messageSound').src="<c:url value="/themes/${sessionScope.loginUser.theme}/sounds/msgAvoke.wav"/>";
	}
} catch(e) {}
</c:if>
<c:if test="${ false && empty newMessageCountRing || newMessageCountRing <= 0}">
try {
	<c:if test="${languages==null || languages=='simpleChinese'}">
		document.getElementById('messageImg').src="<c:url value="/themes/${sessionScope.loginUser.theme}/images/top_message.gif"/>";
	</c:if>
	<c:if test="${languages!=null && languages=='complexChinese'}">
		document.getElementById('messageImg').src="<c:url value="/themes/${sessionScope.loginUser.theme}/images/top_message.gif"/>";
	</c:if>
	<c:if test="${languages!=null && languages=='english'}">
		document.getElementById('messageImg').src="<c:url value="/themes/${sessionScope.loginUser.theme}/images/top_message_en.gif"/>";
	</c:if>
	
	document.getElementById('messageImg').title="${footer_message_6}0${footer_message_7}";
} catch(e) {}
</c:if>

<c:if test="${ false && !empty blebMessages && fn:length(blebMessages) >0}">	
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,i=0;
var obj = document;
<% if ("yes".equals(Constants.USER_THEME_FRAME)) { %>
	if (currentmodule == 'home') {
		obj = parent.ff_main.document;
	} else {
		obj = parent.ff_main.ff_content.document;
	}
<% } %>
function getMsg() {

    var str_eMeng_Count = '${footer_message_3} <c:out value="${fn:length(blebMessages)}"/> ${footer_message_4}';
    var str_eMeng_Content = '';
	
    <c:forEach items="${blebMessages}" var="newMessageInfo" begin="0" end="4">
	<c:set var="myTitle" value="${newMessageInfo.title}"/>
	<c:if test="${fn:length(newMessageInfo.title)>20}">
		<c:set var="myTitle" value="${fn:substring(newMessageInfo.title, 0, 19)}..."/>
	</c:if>
    str_eMeng_Content = str_eMeng_Content + '<a href="<c:url value="/modules/message/messages.do?method=show&id=${newMessageInfo.id}"/>" title="<c:out value="${newMessageInfo.title}"/>"><c:out value="${myTitle}"/></a> <br>';
    </c:forEach>
    var str_eMeng_More = '';
	<c:if test="${fn:length(blebMessages) >5}">
    str_eMeng_More = '<a href="<c:url value="/modules/message/messages.do?ec_s_createdate=desc&type=1"/>">${footer_message_5}</a>';
	</c:if>
	
    try {
	    divTop = parseInt(obj.getElementById("eMeng").style.top,10);
	    divLeft = parseInt(obj.getElementById("eMeng").style.left,10);
	    divHeight = parseInt(obj.getElementById("eMeng").offsetHeight,10);
	    divWidth = parseInt(obj.getElementById("eMeng").offsetWidth,10);
	    docWidth = obj.body.clientWidth;
	    docHeight = obj.body.clientHeight;
	    obj.getElementById("eMeng").style.top = parseInt(obj.body.scrollTop,10) + docHeight - divHeight;
	    obj.getElementById("eMeng").style.left = parseInt(obj.body.scrollLeft,10) + docWidth - divWidth;
	    obj.getElementById("eMeng").style.visibility = "visible";
        obj.getElementById("eMeng_Count").innerHTML = str_eMeng_Count;
		obj.getElementById("eMeng_Content").innerHTML = str_eMeng_Content;
		obj.getElementById("eMeng_More").innerHTML = str_eMeng_More;
    } catch(e) {}
}

function resizeDiv() {
    i+=1
    if (i>500) closeDiv();
    try {
	    divHeight = parseInt(obj.getElementById("eMeng").offsetHeight,10);
	    divWidth = parseInt(obj.getElementById("eMeng").offsetWidth,10);
	    docWidth = obj.body.clientWidth;
	    docHeight = obj.body.clientHeight;
	    obj.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(obj.body.scrollTop,10);
	    obj.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(obj.body.scrollLeft,10);
    } catch(e) {}
}

function moveDiv() {
    try {
	    divTop = parseInt(obj.getElementById("eMeng").style.top,10);
	    obj.getElementById("eMeng").style.top = divTop + 10;
    } catch(e){}
}

function closeDiv() {
	try {
	    obj.getElementById('eMeng').style.visibility='hidden';
	} catch(e) {}
}

if (count == 0) {
	getMsg();
} else { 
	closeDiv();
}

window.onresize = resizeDiv;
window.onscroll = resizeDiv;
</c:if>

if (count == 0) {
	count = 1;
} else {
	count = 0;
}
</script>